package app.cn.com.school.fragment

import android.content.ContentValues
import android.content.Intent
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import app.cn.com.school.R
import app.cn.com.school.activity.ApplyElectActivity
import app.cn.com.school.adapter.PraiseAdapter
import app.cn.com.school.databinding.FragmentPraiseBinding

/**
 * Created by Administrator on 2017/11/1 0001.
 */
class PraiseFragment : BaseFragment<FragmentPraiseBinding>() {
    override fun initBindingVar() {
    }

    var adapter: PraiseAdapter? = null
    var moreList = ArrayList<ContentValues>()

    private var mParam1: String? = null
    private var mParam2: String? = null
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        if (arguments != null) {
            mParam1 = arguments.getString(ARG_PARAM1)
            mParam2 = arguments.getString(ARG_PARAM2)
        }
    }

    override fun onCreateView(inflater: LayoutInflater?, container: ViewGroup?, savedInstanceState: Bundle?): View? {
        initBinding(R.layout.fragment_praise, container)
        mView = binding.root
        initView()
        return super.onCreateView(inflater, container, savedInstanceState)
    }


    private fun initView() {
        binding.titlebar.title.text = "校园评选"
        binding.titlebar.back.visibility = View.GONE
        binding.titlebar.liftText.text = "校区"
        binding.titlebar.liftText.visibility = View.VISIBLE
        binding.titlebar.menuDate.visibility = View.VISIBLE
        binding.titlebar.menuDate.setImageResource(R.mipmap.used_news)

        moreList.add(ContentValues())
        moreList.add(ContentValues())
        moreList.add(ContentValues())


        if (adapter == null) {
            adapter = PraiseAdapter(context, moreList)
            binding.praiseList.adapter = adapter
        }

        binding.praiseList.setOnItemClickListener { parent, view, position, id ->
            startActivity(Intent(context, ApplyElectActivity::class.java))
        }

    }

    companion object {
        private val ARG_PARAM1 = "param1"
        private val ARG_PARAM2 = "param2"
        fun newInstance(param1: String, param2: String): PraiseFragment {
            val fragment = PraiseFragment()
            val args = Bundle()
            args.putString(ARG_PARAM1, param1)
            args.putString(ARG_PARAM2, param2)
            fragment.arguments = args
            return fragment
        }

    }

}